//package patrol.mobile.com.mobilepatrol.persenter;
//
//import com.zhy.http.okhttp.OkHttpUtils;
//
//import org.json.JSONException;
//import org.json.JSONObject;
//
//import okhttp3.Call;
//import patrol.mobile.com.mobilepatrol.api.ByteCallback;
//import patrol.mobile.com.mobilepatrol.api.Urls;
//import patrol.mobile.com.mobilepatrol.bean.Tasks;
//import patrol.mobile.com.mobilepatrol.manager.RoadSurveyManager;
//import patrol.mobile.com.mobilepatrol.utils.Compress;
//import patrol.mobile.com.mobilepatrol.utils.Constants;
//import patrol.mobile.com.mobilepatrol.utils.GsonUtil;
//import patrol.mobile.com.mobilepatrol.utils.SPUtils;
//import patrol.mobile.com.mobilepatrol.view.TaskView;
//
///**
// * Created by apple on 17/9/27.
// */
//
//public class TaskPer {
//    private TaskView mView;
//    String type;
//    public TaskPer(TaskView mView, String type) {
//        this.mView = mView;
//        this.type = type;
//    }
//    public void getTasks() {
//        OkHttpUtils
//                .post()
//                .addParams("type",type)
//                .url(SPUtils.get(Constants.current_ser,"") + Urls.initData)
//                .build()
//                .execute(new ByteCallback() {
//                    @Override
//                    public void onError(Call call, Exception e, int id) {
//
//                    }
//
//                    @Override
//                    public void onResponse(byte[] response, int id) {
//                        try {
//                            String result = Compress.decompressByteArray(response);
//                            JSONObject object = new JSONObject(result);
//                        if (object.getInt("code")==200){
//                            mView.hideLoading();
//                            final JSONObject value = object.getJSONObject("value");
//                            Tasks tasks = GsonUtil.GsonToBean(value.toString(),Tasks.class);
//                            RoadSurveyManager.insertTasks(tasks);
////                            PatrolApp.realm.executeTransactionAsync(new Realm.Transaction() {
////                                @Override
////                                public void execute(Realm realm) {
////                                    realm.createAllFromJson(Tasks.class, value.toString());
////                                }
////                            });
//                            mView.onTaskSuccess(tasks);
//                        }else{
//                            mView.onError("初始化失败");
//                        }
//
//                    } catch (JSONException e) {
//                        e.printStackTrace();
//                    } catch (Exception e) {
//                            e.printStackTrace();
//                    }
//
//                    }
//                });
//    }
//}
